package com.exam.Service;

import com.exam.Entity.Score;
import com.exam.Entity.Student;
import com.exam.Mapper.ScoreMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScoreService {

    @Autowired
    private ScoreMapper scoreMapper;

    public int add(Score score) {
        return scoreMapper.add(score);
    }


    public List<Score> findAll() {
        return scoreMapper.findAll();
    }

    public List<Score> findTotal(Integer sno,int page, int size) {

        List<Score> result = scoreMapper.findById(sno);

        return result;

    }
    public List<Score> findByIdPage(Integer sno,int page,int size) {
        System.out.println(scoreMapper.findById(sno));
        PageHelper.startPage(page, size);
        //执行查询
        List<Score> result = scoreMapper.findById(sno);
        // 包装分页结果
        PageInfo<Score> pageInfo = new PageInfo<>(result);
        return pageInfo.getList();
    }


    public List<Score> findById(Integer sno) {
        return scoreMapper.findById(sno);
    }


    public List<Score> findByExamCode(Integer examId) {
        return scoreMapper.findByExamCode(examId);
    }
}
